<meta charset="utf-8">
<table border = "1" width = "300" height = "600">
	<tr>
		<td colspan = "4"><input id="result" /></td>
	</tr>
	<tr>
		<td><button>C</button></td>
		<td><button onclick = "chu()">/</button></td>
		<td><button onclick = "cheng()">*</button></td>
		<td><button onclick = "qingli()">清理</button></td>
	</tr>
	<tr>
		<td><button onclick="s7()">7</button></td>
		<td><button onclick="s8()">8</button></td>
		<td><button onclick="s9()">9</button></td>
		<td><button onclick = "jian()" id = "jian">-</button></td>
	</tr>
	<tr>
		<td><button onclick="s4()">4</button></td>
		<td><button onclick="s5()">5</button></td>
		<td><button onclick="s6()">6</button></td>
		<td><button onclick="add()" id = "jia">+</button></td>
	</tr>
	<tr>
		<td><button onclick="s1()">1</button></td>
		<td><button onclick="s2()">2</button></td>
		<td><button onclick="s3()">3</button></td>
		<td rowspan = "2"><button onclick="dengYu()">=</button></td>
	</tr>
	<tr>
		<td><button>%</button></td>
		<td><button>0</button></td>
		<td><button onclick="sDot()">.</button></td>
	
	</tr>
</table>

<script>
    var n1;
    var n;
      function dengYu(){ 

      if(n==1){
	result.value=n1+parseFloat(result.value);
      }else if(n==2){
	result.value=n1-parseFloat(result.value);
      }else if(n==3){
	result.value=n1*parseFloat(result.value);
      }else if(n==4){
 	result.value=n1/parseFloat(result.value);
         }
}


    function add(){
        n = 1;
        n1 = parseFloat(result.value);
        result.value = "";
        
    }
   function jian(){
        n = 2;
        n1 = parseFloat(result.value);
        result.value = "";
    }
    function cheng(){
         n = 3;
        n1 = parseFloat(result.value);
        result.value = ""; 
    }
   function chu(){
        n = 4;
        n1 = parseFloat(result.value);
        result.value = "";
    }


    function sDot(){
        if(result.value.indexOf(".")==-1)
            result.value = result.value + ".";
    }

    function s1(){
        result.value = result.value + 1;
    }

    function s2(){
        result.value = result.value + 2;
    }
   function s3(){
        result.value = result.value + 3;
    }

    function s4(){
        result.value = result.value + 4;
    }
    function s5(){
        result.value = result.value + 5;
    }

    function s6(){
        result.value = result.value + 6;
    }

   function s7(){
        result.value = result.value + 7;
    }

    function s8(){
        result.value = result.value + 8;
    }
   function s9(){
        result.value = result.value + 9;
    }
function qingli(){
        result.value = "";
    }
</script>




